<section id="main-content">
  <section class="wrapper">
    <!--state overview end-->
    <div class="row">
      <div class="col-lg-12">
        <section class="panel">
          <header class="panel-heading">
            进展信息
          </header>
          <div class="panel-body">
            <div class="bio-row">
              <p>
                <span>归属项目 </span>{{proName}}</p>
            </div>
            <div class="bio-row line-row">
              <p>
                <span>关键成果 </span>{{krsDesc}}</p>
            </div>
            <div class="bio-row line-row">
              <p>
                <span>进展和困难 </span>{{rwDesc}}</p>
            </div>
            <div class="bio-row line-row">
              <p>
                <span>下一步计划 </span>{{nextStep}}</p>
            </div>
            <div class="bio-row">
              <p>
                <span>成果负责人 </span>{{userName}}</p>
            </div>
            <div class="bio-row">
              <p>
                <span>完成周期 </span>{{finishCycle}}&nbsp;&nbsp;{{start}}</p>
            </div>
            <div class="bio-row">
              <p>
                <span>更新时间 </span>{{updateTime | date:'yyyy-MM-dd HH:mm:ss'}}</p>
            </div>
          </div>
        </section>

        <section class="panel">
          <header class="panel-heading">点评意见*</header>
          <div class="panel-body">
            <div class="form-group customerForm">
                <textarea class="form-control" name="comments" maxlength="250" id="comments" placeholder="最多250个字符"></textarea>
            </div>
          </div>
        </section>

        <section class="panel">
          <div class="panel-body">
            <p class="default-buttons">
              <a href="javascript:void(0);" class="button-back btn btn-info" onclick="window.history.back()">返回</a>
              <a href="javascript:void(0);" class="button-next  btn btn-success btn-l10 agree">确认提交</a>
            </p>
          </div>
        </section>

        <section class="panel">
          <div class="panel-heading">
            我的点评记录
          </div>
          <div class="panel-body">
            <table class="table table-bordered" >
              <thead>
                <tr>
                  <th >提交时间</th>
                  <th>点评内容</th>
                  <th style="text-align:center;">操作</th>
                </tr>
              </thead>
              <tbody id="containerUl">

              </tbody>
            </table>
          </div>
        </section>

      </div>
    </div>
  </section>
</section>
<script type="text/javascript">
  function submitdp(CertusFormAjax,$scope,$routeParams) {
    CertusFormAjax.ajax('findOkrJzdp',{"id":$routeParams.id},function (response) {
      var data = response.data;
      $scope.proName = data.pro_name;
      $scope.rwDesc = data.rw_desc;
      $scope.krsDesc = data.krs_desc;
      $scope.nextStep = data.next_plan;
      $scope.userName = data.user_name;
      $scope.finishCycle = data.finish_cycle;
      $scope.updateTime = data.update_time;
      $scope.proId = data.pro_id;
    });

      CertusFormAjax.ajax('findMySuggestions',{"id":$routeParams.id},function (response) {
          var data = response.data;
          var html = "";
          for (var i = 0; i < data.length; i++) {
              var ftime = new Date(data[i].createTime);
              ftime = $.fn.dlshouwen.grid.tools.dateFormat(ftime, "yyyy-MM-dd hh:mm:ss");
              html+="<tr><td style='width:140px;'>"+ftime+"</td>";
              html+="<td>"+data[i].comments+"</td>";
              // 计算相差多少天
              var d = new Date();
              start=ftime.replace(/-/g,"/");
              var startdate=new Date(start);
              var time=d.getTime()-startdate.getTime();
              var days=parseInt(time/(1000 * 60 * 60 * 24));
              // 大于三天则不能修改和删除
              if (days<=3){
                  html+="<td style='text-align:center;width:70px;'><button class='btn btn-xs btn-danger' onclick='deldp(\""+data[i].id+"\");'>" +
                      "<i class='fa fa-trash-o'></i>删除</button></td>";
              }else{
                  html+="<span>超过三天</span>";
              }
              html+="</tr>";
          };
          $("#containerUl").append(html);
      });
      
      $(".agree").click(function () {
          var comments = $("#comments").val();
          if (comments==""){
              layer.msg("点评意见不能为空",{"time":1000});
              return;
          }
          CertusFormAjax.ajax('addProdpOkr',{"id":$routeParams.id,"comments":comments,"proId":$scope.proId},function () {
              layer.msg("添加成功",{"time":1000});
              window.history.back();
          });
      });

      this.deldp = function (id) {
          layer.confirm('确认删除此数据？', {
              btn: ['确定', '取消'] //按钮
          }, function () {
              CertusFormAjax.ajax("delJzdp",{"id":id},function () {
                  layer.msg("删除成功",{"time":1000});
                  window.location.reload();
              });
          })
      }
  }

</script>